package com.wanxi.test;

import com.wanxi.uitl.IOTool;

import java.io.*;

public class CopyFileBuffer {
    public static void main(String[] args) {
        String oldPath = "E:\\wanxi\\canyin02-20230213\\day19IO流\\src\\com\\wanxi\\test\\aaa\\3.jpg";
        String path = "E:\\wanxi\\canyin02-20230213\\day19IO流\\src\\com\\wanxi\\test\\bbb";
        String fileName = "5.jpg";
        File file = IOTool.createFile(path, fileName);
        try {
            OutputStream outputStream = new FileOutputStream(file);
            BufferedOutputStream bufferedOutputStream =
                    new BufferedOutputStream(outputStream);
            BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(oldPath));
            int aa = 0;
            while ((aa = bufferedInputStream.read()) != -1) {
                bufferedOutputStream.write(aa);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
